package com.eightywork.life.fragment;

import com.eightywork.life.R;
import com.eightywork.life.service.CacheService;
import com.eightywork.life.service.DataService;
import com.eightywork.life.widget.ActionsContentView;
import com.umeng.analytics.MobclickAgent;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;

public class SpaceFragment extends BaseFragment implements OnClickListener {
	public static final String TAG = SpaceFragment.class.getName();
	private ActionsContentView viewActionsContentView;
	private FragmentManager fm;
	private FragmentTransaction tr;

	public Fragment changeFragmentAnOnResume(Fragment changeFragment,
			Bundle args) {
		fm = getActivity().getSupportFragmentManager();
		tr = fm.beginTransaction();
		if (args != null)
			changeFragment.setArguments(args);
		tr.replace(R.id.space_content, changeFragment);
		tr.commitAllowingStateLoss();
		return changeFragment;
	}
	
	@Override
	public void onResume() {
		super.onResume();
	    MobclickAgent.onResume(getActivity());
	}
	
	@Override
	public void onPause() {
	    super.onPause();
	    MobclickAgent.onPause(getActivity());
	}

	public SpaceFragment(Activity context,
			ActionsContentView viewActionsContentView) {
		this.viewActionsContentView = viewActionsContentView;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.fragment_space, container, false);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		initView();
		initData();
		super.onActivityCreated(savedInstanceState);
	}

	private void initView() {
		initHeader("个人空间", viewActionsContentView);
		Bundle bundle = new Bundle();
	//	bundle.putSerializable("count", getArguments().getString("count"));
//		bundle.putSerializable("messageCount", getArguments().getString("messageCount"));
//		bundle.putSerializable("pmcount", getArguments().getString("pmcount"));
		bundle.putSerializable("uid", CacheService.getSpace().getUid());
		changeFragmentAnOnResume(new SpaceContentFragment(), bundle);
	}
	


	private void initData() {
	}

	@Override
	public void onClick(View v) {
	}
}
